package com.login;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class ManagerDaoHibernate extends HibernateDaoSupport implements
		ManagerDao {
	public Manager get(String id) {
		return ((Manager) getHibernateTemplate().get(Manager.class, id));
	}

	public Manager findManager(String id, String pass) {
		String args[]={id,pass};
		List list = getHibernateTemplate().find(
				"from com.login.Manager ma where ma.id=? and ma.pass=?", args);
		if(list.size()==1){
			return (Manager)list.get(0);
		}
		return null;
	}
	
	public void updateManager(String id,String pass,String name){
		Manager manager=new Manager();
		manager.setId(id);
		manager.setPass(pass);
		manager.setName(name);
		getHibernateTemplate().saveOrUpdate(manager);
	}
}
